import { get } from '@/api/index.js'
import { ElMessage } from "element-plus";
export const login = async function (query, sucMsg, errMsg) {
    try {
        const res = await get('/api/login', query)
        if (res.code === 0) {
            ElMessage.success(sucMsg || '成功')
            return res.data
        } else {
            ElMessage.error(errMsg || res.msg)
            return Promise.reject(res.msg)
        }
    } catch (e) {
        console.error(e);
        ElMessage.error(errMsg || '失败')
        return Promise.reject('发生错误！请联系开发者')
    }
}

export const authentication = async () => {
    return await get('/api/authentication')
}